﻿namespace MDXStudio.MdSchema
{
    using System;
    using System.Data;

    internal class MdSet : IMdObject
    {
        private string mCubeName;
        private string mDescription;
        private string mDimensions;
        private string mDisplayFolder;
        private string mExpression;
        private int mScope;
        private string mSetCaption;
        private string mSetName;
        private string mSetUniqueName;

        public MdSet(DataRow pRow)
        {
            this.mCubeName = (string) pRow["CUBE_NAME"];
            this.mSetName = (string) pRow["SET_NAME"];
            this.mSetUniqueName = "[" + this.mSetName + "]";
            this.mSetCaption = (string) pRow["SET_CAPTION"];
            this.mDescription = (pRow["DESCRIPTION"] is DBNull) ? string.Empty : ((string) pRow["DESCRIPTION"]);
            this.mScope = (int) pRow["SCOPE"];
            this.mExpression = pRow["EXPRESSION"] as string;
            this.mDimensions = (string) pRow["DIMENSIONS"];
            this.mDisplayFolder = ((pRow.Table.Columns.IndexOf("SET_DISPLAY_FOLDER") < 0) || (pRow["SET_DISPLAY_FOLDER"] is DBNull)) ? string.Empty : ((string) pRow["SET_DISPLAY_FOLDER"]);
        }

        public override string ToString()
        {
            return this.mSetCaption;
        }

        public string Caption
        {
            get
            {
                return this.mSetCaption;
            }
        }

        public string CubeName
        {
            get
            {
                return this.mCubeName;
            }
        }

        public string Description
        {
            get
            {
                return this.mDescription;
            }
        }

        public string Dimensions
        {
            get
            {
                return this.mDimensions;
            }
        }

        public string DisplayFolder
        {
            get
            {
                return this.mDisplayFolder;
            }
        }

        public string Expression
        {
            get
            {
                return this.mExpression;
            }
        }

        public string Name
        {
            get
            {
                return this.mSetName;
            }
        }

        public int Scope
        {
            get
            {
                return this.mScope;
            }
        }

        public string UniqueName
        {
            get
            {
                return this.mSetUniqueName;
            }
        }
    }
}

